package com.edushare.common.util;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;

public class MonthNameValue implements Serializable{
	
	private static final long serialVersionUID = -8071045991238408391L;
	private String monthName;
	private Integer monthValue;
	public static final HashMap<Integer,String> moMap = new HashMap<Integer, String>();
	
	static{
		moMap.put(new Integer(1), "January");
		moMap.put(new Integer(2), "February");
		moMap.put(new Integer(3), "March");
		moMap.put(new Integer(4), "April");
		moMap.put(new Integer(5), "May");
		moMap.put(new Integer(6), "June");
		moMap.put(new Integer(7), "July");
		moMap.put(new Integer(8), "August");
		moMap.put(new Integer(9), "September");
		moMap.put(new Integer(10), "October");
		moMap.put(new Integer(12), "November");
		moMap.put(new Integer(12), "December");
	}
	
	public MonthNameValue() {
	}
	
	public MonthNameValue(Date d){
		if(d!=null)
		{
			int key = Integer.parseInt((new SimpleDateFormat("MM")).format(d));
			this.monthValue = key;
			this.monthName = moMap.get(key);
		}
	}

	public void setMonth(Date d){
		if(d!=null)
		{
			int key = Integer.parseInt((new SimpleDateFormat("MM")).format(d));
			this.monthValue = key;
			this.monthName = moMap.get(key);
		}
	}
	
	public String getMonthName() {
		return monthName;
	}
	public void setMonthName(String monthName) {
		this.monthName = monthName;
	}
	public Integer getMonthValue() {
		return monthValue;
	}
	public void setMonthvalue(Integer monthValue) {
		this.monthValue = monthValue;
	}
	
	public static ArrayList<MonthNameValue> getMonthList(){
		ArrayList<MonthNameValue> moli = new ArrayList<MonthNameValue>();
		
		for(Integer key: moMap.keySet()){
			MonthNameValue mo = new MonthNameValue();
			mo.setMonthvalue(key);
			mo.setMonthName(moMap.get(key));
			moli.add(mo);
		}
		
		
		return moli;
	}
}
